<?
	mysql_connect("localhost","root","root");
	mysql_select_db("database");
	mysql_query("SET NAMES UTF8");
	
	if(trim($_POST["mcdr_cl_email"]) == "")
	{
		echo "Please input Email !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}
	if(trim($_POST["mcdr_cl_password"]) == "")
	{
		echo "Please input Password !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}
	if(strlen($mcdr_cl_password)<6 or strlen($mcdr_cl_password)>15)
	{	
		echo "Please input password and minimum 6 charactor !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	
		
	if($_POST["mcdr_cl_password"] != $_POST["mcdr_cl_re-password"])
	{
		echo "Password not Match !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();
	}
	
	if(trim($_POST["mcdr_cl_clinic"]) == "")
	{
		echo "Please input Nme Doctor !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

	if(trim($_POST["mcdr_cl_yourname"]) == "")
	{
		echo "Please input Nme Clinic !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

	if(trim($_POST["mcdr_cl_add"]) == "")
	{
		echo "Please input Address !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

	if(trim($_POST["mcdr_cl_tel"]) == "")
	{
		echo "Please input Phone Numder !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

 

	
	$strSQL = "SELECT * FROM member_mcdr_cl WHERE mcdr_cl_email = '".trim($_POST['mcdr_cl_email'])."' ";
	$objQuery = mysql_query($strSQL);
	$objResult = mysql_fetch_array($objQuery);
	mysql_query("SET NAMES UTF8");
	if($objResult)
	{
			echo "Username already exists!";
			echo "<br> Go to <a href='C-Dr.php#join_form4'>Back</a>";
	}
	else
	{	
		

		$strSQL = "INSERT INTO member_mcdr_cl (mcdr_cl_email,mcdr_cl_password,mcdr_cl_whois,mcdr_cl_clinic,mcdr_cl_yourname,mcdr_cl_sex,mcdr_cl_add,mcdr_cl_tambon,mcdr_cl_amphur,mcdr_cl_town,mcdr_cl_post,mcdr_cl_tel) VALUES ('".$_POST["mcdr_cl_email"]."', 		'".$_POST["mcdr_cl_password"]."','".$_POST["mcdr_cl_whois"]."','".$_POST["mcdr_cl_clinic"]."','".$_POST["mcdr_cl_yourname"]."','".$_POST["mcdr_cl_sex"]."','".$_POST["mcdr_cl_add"]."','".$_POST["mcdr_cl_tambon"]."','".$_POST["mcdr_cl_amphur"]."','".$_POST["mcdr_cl_town"]."','".$_POST["mcdr_cl_post"]."','".$_POST["mcdr_cl_tel"]."')";

		
		$objQuery = mysql_query($strSQL);
		mysql_query("SET NAMES UTF8");
		
 		header("location:C-Dr.php");		
	}

	mysql_close();
?>

<!--x  สมัครสมาชิก ตัวแทนศัลยกรรม    x--> 	